<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
	$USER = $this->user_entity->init('id',$USER->getId());
?>
<style>
	#wrap-change-email,
	#wrap-change-password{margin-top:10px;}
	
	#update-message{margin-top:5px;}
	
	.select-box label{float:left;width:150px;}
	
	.input-error{width:250px;}
</style>


<div id="content-left">
	<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left">
						<span><?php echo language_translate('right_nav_account_email');?></span>
						<div class="help-text" title="<?php echo language_translate('right_nav_edit_account_email_hint');?>"></div>
					</div>
					<div class="dashboard-info-right">
						<div class="select-box" id="email_text">
							<?php echo $USER->getEmail();?>
						</div>
						<div class="select-box" id="email_text">
							<a href="javascript:void(0);" id="link_change_email">
								<?php echo language_translate('right_nav_change');?>
							</a>
						</div>
						<div class="clear"></div>
						
						<div id="wrap-change-email" class="hidden">
							<div class="select-box">
								<input type="text" name="account_email" id="account_email" value="<?php echo $USER->getEmail();?>" maxlength="45" class="text-box3">
							</div>
							 
							<div class="select-box">
								<input type="submit" onclick="return do_save_change_email();" class="save-button" value="<?php echo language_translate('appareance_save');?>" /> 
							</div>
							<?php echo loader_image("id='loader_image_change_email' class='hidden'");?>
							<div class="clear"></div>
							<div class="input-error" id="account_email_err" ></div>
							<div class="clear"></div>
							<div id="update-message" class="change_email_done"><?php echo language_translate('update_successfully_message');?></div>
						</div>
						
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
			  
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('right_nav_account_password');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box" id="email_text">
							<a href="javascript:void(0);" id="link_change_password">
								<?php echo language_translate('right_nav_change');?>
							</a>
						</div>
						<div class="clear"></div>
						
						<div id="wrap-change-password" class="hidden">
							<div class="select-box">
								<label><?php echo language_translate('right_nav_old_passwd');?></label>
								<input type="password" name="account_password" id="account_password" value="" maxlength="45" class="text-box3">
							</div>
							<div class="clear"></div>
							<div class="select-box">
								<label><?php echo language_translate('right_nav_new_passwd');?></label>
								<input type="password" name="account_password2" id="account_password2" value="" maxlength="45" class="text-box3">
							</div>
							
							<div class="clear"></div> 
							<div class="select-box">
								<input type="submit" onclick="return do_save_change_password();" class="save-button" value="<?php echo language_translate('appareance_save');?>" /> 
							</div>
							<?php echo loader_image("id='loader_image_change_password' class='hidden'");?>
							<div class="clear"></div>
							<div class="input-error" id="account_passwd_err" ></div>
							<div class="clear"></div>
							<div id="update-message" class="change_passwd_done"><?php echo language_translate('update_successfully_message');?></div>
						</div>
						
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
		</div>
	</div>
</div>

<?php $this->load->view('agent/right_nav'); ?>



<script type="text/javascript">
$(document).ready(function() { 
	$('#link_change_email').click(function(){
		$('#wrap-change-email').toggle();
	});
	$('#link_change_password').click(function(){
		$('#wrap-change-password').toggle();
	});
	$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
});	
 
function do_save_change_email(){
	$email = $('#account_email').attr('value');
	$('#loader_image_change_email').toggle();
	$('#account_email_err').html('');
	$.post(BASE_URI+'agent/my_account/save_change_email',{email:$email},function(res){
		$('#loader_image_change_email').toggle();
		if(res.status == 'ok'){
			updatedShow('change_email_done');
			//$('#email_text').html($email);
			//$('#wrap-change-email').fadeOut(TIMEDELAY );
		}else{
			$('#account_email_err').html(res.msg);
		}
	} ,'json');
} 

function do_save_change_password(){
	$passwd = $('#account_password').attr('value');
	$passwd2 = $('#account_password2').attr('value');
	$('#loader_image_change_password').toggle();
	$('#account_passwd_err').html('');
	$.post(BASE_URI+'agent/my_account/save_change_password',{passwd:$passwd,passwd2:$passwd2},function(res){
		$('#loader_image_change_password').toggle();
		if(res.status == 'ok'){
			updatedShow('change_passwd_done');
		}else{
			$('#account_passwd_err').html(res.msg);
		}
	} ,'json');
}
</script>